<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改车辆申请')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-process-edit" th:object="${carProcess}">
            <h4 class="form-header h4">车辆申请信息</h4>
            <input name="processId" th:field="*{processId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">紧急程度：</label>
                <div class="col-sm-8">
<!--                    <input name="urgent" th:field="*{urgent}" class="form-control" type="text">-->
                    <select name="urgent" id="urgent">
                        <option th:value="*{urgent}" th:text="*{urgent}" class="form-control"></option>
                        <option value="普通">普通</option>
                        <option value="略紧急">略紧急</option>
                        <option value="紧急">紧急</option>
                    </select>
                </div>
            </div>
          <!--  <div class="form-group">
                <label class="col-sm-3 control-label">借用车辆：</label>
                <div class="col-sm-8">
                    <input name="usedCar" th:field="*{usedCar}" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">用车事由：</label>
                <div class="col-sm-8">
                    <input name="reason" th:field="*{reason}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startTime" th:value="${#dates.format(carProcess.startTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endTime" th:value="${#dates.format(carProcess.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">始发地：</label>
                <div class="col-sm-8">
                    <input name="startLocation" th:field="*{startLocation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">目的地：</label>
                <div class="col-sm-8">
                    <input name="endLocation" th:field="*{endLocation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
         <!--   <div class="form-group">
                <label class="col-sm-3 control-label">创建人 应为当前用户姓名：</label>
                <div class="col-sm-8">
                    <input name="creater" th:field="*{creater}" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="createdTime" th:value="${#dates.format(carProcess.createdTime, 'yyyy-MM-dd')}" disabled class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
          <!--  <h4 class="form-header h4">车辆列信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/process";
        $("#form-process-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-process-edit').serialize());
            }
        }

        $("input[name='startTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='createdTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            var options = {
                data: [[${carProcess.carListList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'name',
                    align: 'center',
                    title: '车辆名称 车辆名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].name' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'color',
                    align: 'center',
                    title: '车辆颜色 车辆颜色',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].color' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'card',
                    align: 'center',
                    title: '车牌 车牌号',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].card' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'status',
                    align: 'center',
                    title: '状态 车辆状态',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].status' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'driver',
                    align: 'center',
                    title: '司机 车主id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].driver' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'creater',
                    align: 'center',
                    title: '创建人 创建人id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].creater' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'createdTime',
                    align: 'center',
                    title: '创建时间 创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].createdTime' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'text',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='carListList[%s].text' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                name: "",
                color: "",
                card: "",
                status: "",
                driver: "",
                creater: "",
                createdTime: "",
                text: "",
            }
            sub.addRow(row);
        }
    </script>
</body>
</html>